<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
	<title>{{.title}}</title>
	<script src="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/wechat/frame/mui/js/mui.min.js"></script>
	<link rel="stylesheet" href="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/wechat/frame/mui/css/mui.min.css">
	<link href="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/wechat/css/app.css?v=042405" rel="stylesheet" />
	<link rel="stylesheet" href="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/wechat/frame/sui/css/SUI.css?v=1">
	<link rel="stylesheet" href="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/wechat/font/iconfont.css">
	<link href="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/wechat/frame/mui/css/mui.picker.css" rel="stylesheet" />
	<link href="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/wechat/frame/mui/css/mui.poppicker.css" rel="stylesheet" />
	<script src="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/wechat/frame/mui/js/mui.picker.js"></script>
	<script src="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/wechat/frame/mui/js/mui.poppicker.js"></script>
	<script src="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/wechat/frame/mui/js/city.data-3.js" type="text/javascript" charset="utf-8"></script>
</head>
<style type="text/css">
		.suiLineInput dl input{margin: 0!important;padding:0;}
		.suiLineInput dl{min-height: 41px !important}
		.suiTag{margin: 0}
		.sure{margin-bottom: 20px;}
		button.mui-btn{border: #e54242}
</style>
<body class="storeapply">
	<p class="suiTag">基本信息</p>
	<form id="form">
	<div class="suiLineInput strong">
		<dl>
			<dt>选择类型</dt>
			<dd id="type">{{if .json}}{{if eq .json.type "0"}}个人{{else}}店铺{{end}}{{else}}请选择类型{{end}}</dd>
			<input type="hidden" name="type" value="{{.json.type}}">
		</dl>
		<dl>
			<dt>真实姓名</dt>
			<dd><input type="text" name="name" placeholder="请输入真实姓名" value="{{.json.name}}"></dd>
		</dl>
		<dl>
			<dt>手机号码</dt>
			<dd>
				<input type="tel" pattern="[0-9]*" name="mobile" placeholder="请输入手机号码" value="{{.json.mobile}}">
			</dd>
		</dl>
	</div>
	<p class="suiTag">认证信息</p>
	<div class="suiLineInput strong">
		<dl>
			<dt>身份证号码</dt>
			<dd><input type="text" onkeyup="cardreplace(this)" placeholder="请输入身份证号码" name="card" value="{{.json.card}}"></dd>
		</dl>
		<dl class="uploadImg">
			<dt>身份证照片</dt>
			<dd style="background-image: url({{if .json.pathname1}}{{.json.pathname1}}{{else}}/static/wechat/img/add.png{{end}});">
				<input type="file" onchange='sword_uppic(this,"promotion")' accept="image/*">
				<input type="hidden" name="cardimg" value="{{.json.cardimg}}">
			</dd>
		</dl>
		<dl class="uploadImg">
			<dt>手持身份证</dt>
			<dd style="background-image: url({{if .json.pathname2}}{{.json.pathname2}}{{else}}/static/wechat/img/add.png{{end}});">
				<input type="file" onchange='sword_uppic(this,"promotion")' accept="image/*">
				<input type="hidden" name="imgcard" value="{{.json.imgcard}}">
			</dd>
		</dl>
		<input type="hidden" name="id" value="{{.json.id}}">
		<input type="hidden" name="style" value="{{if .json}}{{.json.style}}{{else}}{{.style}}{{end}}">
	</div>
	<p class="suiTag">申请理由（选填）</p>
	<div class="suiLineInput strong">
		<dl class="text">
			<dd><textarea cols="30" rows="10" placeholder="请输入申请理由" name="content">{{.json.content}}</textarea></dd>
		</dl>
	</div>
	</form>
	<button class="sure" id="save">保存</button>
</body>
</html>
<script type="text/javascript" src="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/wechat/frame/sui/js/SUI.js"></script>
<script type="text/javascript" src="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/wechat/js/card.js"></script>
<script type="text/javascript" src="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/wechat/js/zepto.min.js"></script>
<script type="text/javascript" src="https://tcsc.oss-cn-hangzhou.aliyuncs.com/static/wechat/js/sword_uppic.js"></script>
{{template "wechat/public/share.html" .}}
<script type="text/javascript">
	function cardreplace(e){
		var regu='\\d|[xX]'
		var re = new RegExp(regu);
		var v=e.value
		v=v.split('')
		for (var i=0;i<v.length;i++){
			if(!re.test(v[i])){
				v[i]=''
			}
			if(i>=18){
				v[i]=''
			}
		}
		e.value=v.join('')
	}
	document.getElementById('save').addEventListener('tap',function(){
		var that=this
		var form=serialize('form')
		if(form.type==""){
			mui.toast("请选择类型~");return false;
		}
		if(form.name==""){
			mui.toast("请输入真实姓名~");return false;
		}
		if(form.mobile.length!=11){
			mui.toast("请输入正确的手机号码~");return false;
		}
		if(testcard(form.card)!="ok"){
			mui.toast(testcard(form.card));return false;
		}
		if(form.cardimg==""){
			mui.toast("请上传身份证照片~");return false;
		}
		if(form.imgcard==""){
			mui.toast("请上传手持身份证照片~");return false;
		}
		that.disabled=true
		mui.ajax(window.location.href,{
			type:'post',
			data:form,
			dataType:'json',
			timeout:10000,
			success: function(data){
			if (data==1) {
				mui.alert("提交成功，请等待审核","",function () {
					window.location.href="/mobile/my"
				});
			}else if(data==2){
				mui.toast("请不要重复提交!");
			}else{
				mui.toast("网络繁忙，请重试~");
			}
			that.disabled=false
			},
			error: function(xhr, type){
				mui.toast("网络慢，请重试");
				that.disabled=false
			// 即使加载出错，也得重置
			}
		});

	})

			//普通示例
	var userPicker = new mui.PopPicker();
	userPicker.setData([{
		text: '个人',
		value:'0'
	}, {
		text: '店铺',
		value:'1'
	}]);
	var type = document.getElementById('type');
	var type2=document.getElementsByName("type")[0]
	type.addEventListener('tap', function(event) {
		userPicker.show(function(items) {
			type.innerHTML =items[0].text;
			type2.value=items[0].value
		});
	}, false);
</script>